package com.platform.service.impl;

import com.platform.cache.J2CacheUtils;
import com.platform.dao.BannerDao;
import com.platform.entity.BannerEntity;
import com.platform.service.BannerService;
import com.platform.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2019-02-16 13:37:34
 */
@Service("bannerService")
public class BannerServiceImpl implements BannerService {
    @Autowired
    private BannerDao bannerDao;

    @Override
    public BannerEntity queryObject(Long id) {
        return bannerDao.queryObject(id);
    }

    @Override
    public List<BannerEntity> queryList(Map<String, Object> map) {
        return bannerDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return bannerDao.queryTotal(map);
    }

    @Override
    public int save(BannerEntity tBanner) {
        //清理KEY="HOME_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_HOME);
        return bannerDao.save(tBanner);
    }

    @Override
    public int update(BannerEntity tBanner) {
        //清理KEY="HOME_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_HOME);
        return bannerDao.update(tBanner);
    }

    @Override
    public int delete(Long id) {
        //清理KEY="HOME_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_HOME);
        return bannerDao.delete(id);
    }

    @Override
    public int deleteBatch(Long[] ids) {
        //清理KEY="HOME_KEY"在Redis的缓存
        J2CacheUtils.clear(Constants.REDIS_HOME);
        return bannerDao.deleteBatch(ids);
    }
}
